// Main header
#include "../Main.h"

// My header
#include "Controller_Screen_Main.h"

// Fridge
#include "Controller_Main.h"
#include "../StringHash.h"
#include "../Widgets/Button.h"
#include "../Widgets/Panel.h"
#include "../Widgets/StaticText.h"

bool		Controller_Screen_Main::s_bVisible		= false;

enum MAIN_MENU_BUTTONS
{
	MAIN_MENU_WATCH = 0,
	MAIN_MENU_CREATE,
	MAIN_MENU_QUIT,

	MAIN_MENU_NUM_BUTTONS
};

void Controller_Screen_Main::Show ()
{
	if( s_bVisible )
	{
		return;
	}

	Panel* pxPanel = new Panel( Controller_Main::GetWindowPanel() );
	pxPanel->SetPosition( 200, 0 );
	pxPanel->SetSize( 512, 256 );
	pxPanel->SetImage( GetStringHash( "LogoMain" ) );
	pxPanel->SetAnchors( ANCHOR_TOP | ANCHOR_RIGHT );

	for( u_int uButton = 0; uButton < MAIN_MENU_NUM_BUTTONS; ++uButton )
	{
		Button* pxButton = new Button( Controller_Main::GetWindowPanel() );

		if( !pxButton )
		{
			continue;
		}

		switch( uButton )
		{
			case MAIN_MENU_WATCH:
			{
				pxButton->SetPosition( 60, 350 );
				pxButton->SetSize( 200, 50 );
				pxButton->SetButtonPressCallback( 0, 0 );
				pxButton->SetLabel( "Watch" );
				pxButton->SetAnchors( ANCHORS_BOTTOMLEFT );
			}
			break;

			case MAIN_MENU_CREATE:
			{
				pxButton->SetPosition( 60, 410 );
				pxButton->SetSize( 200, 50 );
				pxButton->SetButtonPressCallback( ButtonCallback_Editor, 0 );
				pxButton->SetLabel( "Create" );
				pxButton->SetAnchors( ANCHORS_BOTTOMLEFT );
			}
			break;

			case MAIN_MENU_QUIT:
			{
				pxButton->SetPosition( 60, 470 );
				pxButton->SetSize( 200, 50 );
				pxButton->SetButtonPressCallback( ButtonCallback_Quit, 0 );
				pxButton->SetLabel( "Quit" );
				pxButton->SetAnchors( ANCHORS_BOTTOMLEFT );
			}
			break;
		}
	}

	s_bVisible = true;
}


void Controller_Screen_Main::Hide ()
{
	if( !s_bVisible )
	{
		return;
	}

	s_bVisible = false;
}

void Controller_Screen_Main::ButtonCallback_Quit( void* pUserData )
{
	Controller_ModalDialog::SetCallback( DialogCallback_Quit );
	Controller_ModalDialog::Show( "Are you sure you want to quit?", DIALOGTYPE_YESNO );
}

void Controller_Screen_Main::DialogCallback_Quit( const Controller_ModalDialogResult eType )
{
	if( eType == DIALOGRESULT_YES )
	{
		Controller_Main::Quit();
	}
}

void Controller_Screen_Main::ButtonCallback_Editor( void* pUserData )
{
	Controller_Main::ChangeScreen( CONTROLLER_SCREEN_EDITOR );
}

//eof
